using BasecampRestAPI;
using NUnit.Framework;
using TestBasecampRestAPI.TestMoveToDoList;

namespace TestBasecampRestAPI
{
	public class TestProjectBaseFixture
	{
		protected FakeBaseCamp _camp;
		protected FakeRestWebService _service;
		protected IProject _project;

		[SetUp]
		public void SetUp()
		{
			_camp = FakeBaseCamp.GetInstance();
			_service = FakeRestWebService.GetInstance();
			_camp.ServiceGetFakeResult = _service;
			_project = Project.GetInstance(_camp,
			                               TestBasecamp.GetElementForXml(Properties.Resources.FakeProject));
		}

		protected void SetupResponseXml(string xml)
		{
			_service.GetRequestResponseElementFakeResult = TestBasecamp.GetElementForXml(xml);
		}

		protected void AssertGetRequestCalledForPath(string path)
		{
			Assert.IsTrue(_service.GetRequestResponseElementCalled);
			Assert.IsTrue(_service.GetRequestResponseElementCalledForPath(path));
		}

		protected void AssertGetRequestForAction(string action)
		{
			AssertGetRequestCalledForPath(string.Format("projects/{0}/{1}", _project.Id, action));
		}
	}
}